import request from '@/utils/request';
import axiosUpdate from "@/utils/http";
/* eslint-disable */
const rwsUrl =
  process.env.NODE_ENV === 'development'
    ? 'http://dev.c85eaf0d05d04465a81befded3f4f608b.cn-shenzhen.alicontainer.com'
    : window.location.origin;
const authorityUrl =
  process.env.NODE_ENV === 'development'
    ? 'http://dev.c85eaf0d05d04465a81befded3f4f608b.cn-shenzhen.alicontainer.com'
    : window.location.origin;
//对于客户中心配置通用配置进行查询
export function getCustomerConfig(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/config/getCustomerConfig?type=${data.type}`
  );
}

// 获取task list
export function getOutTaskList(params) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/feedBack/getOutTaskList`,
    method: 'POST',
    data: { ...params },
  });
}

// dictionary配置查询
export function getDictionaryConfig(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/common/getDictionaryConfig?dictType=${
      data.dictType
    }&dictSubType=${data.dictSubType}`
  );
}

// userGrouping配置查询
export function queryUserGroupsWithMembers(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/user/group/queryUserGroupsWithMembers?groupType=${data.groupType}`
  );
}

// getAttachDetailValueList配置查询
export function getAttachDetailValueList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/common/getAttachDetailValueList?valueCode=${data.valueCode}`
  );
}

// queryUserGroupMembersByUserId
export function queryUserGroupsByUserId(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/user/group/queryUserGroupsByUserId?id=${data.userId}&groupType=${
      data.groupType
    }`
  );
}

// customers_card_detail
export function queryCustomersCardDetail(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customers_card_detail?customerId=${data.customerId}`
  );
}
// getTicketTracking
export function getTicketTracking(params) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/tracking/getTaskTracking`,
    method: 'POST',
    data: { ...params },
  });
}
// outTaskAction
export function outTaskAction(params) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/feedBack/outTaskAction`,
    method: 'POST',
    data: { ...params },
  });
}
// addCustConsider
export function addCustConsider(params) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/feedBack/addCustConsider`,
    method: 'POST',
    data: { ...params },
  });
}

// 查询用户权限
export function getUserAuthorities(params) {
  // 'portal' 用window.AppGlobal.webroot代替
  return axiosUpdate.get(
    `${authorityUrl}${window.AppGlobal.webroot || '/portal'}/components/independents/${
      params.userId
    }`
  );
}
// 查询客户明细信息
export function getProfileDetail(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customers_detail?customerId=${data.customerId}`
  );
}

// getActivityAnalysis
export function getActivityAnalysis(params) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/feedBack/getActivityAnalysis`,
    method: 'POST',
    data: { ...params },
  });
}
// fuzzyQueryCampaignName
export function fuzzyQueryCampaign(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/campaign/fuzzyQueryCampaign?sasCode=${data.sasCode}&campaignName=${data.campaignName}`
  );
}

// queryCustConsideration
export function queryCustConsideration(params) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/feedBack/queryCustConsideration`,
    method: 'POST',
    data: params,
  });
}

// queryEventLog
export function queryEventLog(params) {
  const {currentPage=1,pageSize=5,feedbackId:tempFeedbackId=''}=params;
  let {orderBy='CREATED_TIME DESC'}=params;
  if(!orderBy){orderBy='CREATED_TIME DESC'}
  let feedbackId = '';
  if(tempFeedbackId){
    feedbackId = `&feedbackId=${tempFeedbackId}`
  }
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/tracking/queryEventLog?currentPage=${currentPage}&pageSize=${pageSize}${feedbackId}&orderBy=${orderBy}`,
    method: 'GET',
  });
}

//getInactiveUserList
export function queryInactiveUserGroupsByUserId(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/user/group/queryInactiveUserGroupsByUserId?id=${data.userId}&groupType=${
      data.groupType
      }`
  );
}
//getProjectWinList
export function GetProjectWinList(params = { dictType: '10', dictSubType: '1002' }) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/report/queryDictionary`,
    method: 'GET',
    params,
  });
}
//getRFMLabelList
export function GetRFMLabelList(params = { dictType: '10', dictSubType: '1003' }) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/report/queryDictionary`,
    method: 'GET',
    params,
  });
}

//getCustomerNationalList
export function getCustomerNationalList(params = { tableName: 'CUST_PROFILE', columnName: 'NOTIONALITY' }) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/customer/common/domain_infos`,
    method: 'GET',
    params,
  });
}







